package com.sunyard.domee.controller;


import com.sunyard.domee.common.model.BaseController;
import com.sunyard.domee.common.model.PageListResult;
import com.sunyard.domee.common.model.ResultModel;
import com.sunyard.domee.controller.convert.MarketingCouponConvert;
import com.sunyard.domee.controller.vo.MarketingCouponVO;
import com.sunyard.domee.dal.query.MarketingCouponQuery;
import com.sunyard.domee.handler.MarketingCouponHandler;
import com.sunyard.domee.service.bo.MarketingCouponBO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 优惠券
 * 
 * @author xw
 * @email wei.xiao  çæææ
 * @date 2020-07-02 22:52:45
 */
@RestController
@RequestMapping("/washCarMarketingCoupon")
public class MarketingCouponController extends BaseController {
	@Resource
	private MarketingCouponHandler marketingCouponHandler;


	
	/**
	 * 分页列表
	 */
	@GetMapping("/findPage")
	public ResultModel findPageInfo(MarketingCouponQuery condition){
		PageListResult<MarketingCouponBO> page = marketingCouponHandler.findPage(condition);
		PageListResult<MarketingCouponVO> pageListResult = new PageListResult(MarketingCouponConvert.toVOList(page.getList()), page.getPageNum(), page.getPageSize(), page.getTotal());
		return new ResultModel(pageListResult);
	}

	/**
	 * 添加
	 */
	@RequestMapping("/add")
	@ResponseBody
	public ResultModel add(@RequestBody MarketingCouponVO marketingCouponVO){
		MarketingCouponBO marketingCouponBO = MarketingCouponConvert.toBO(marketingCouponVO);
        return new ResultModel(marketingCouponHandler.add(marketingCouponBO));
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@ResponseBody
	public ResultModel update(@RequestBody MarketingCouponVO marketingCouponVO){
		MarketingCouponBO marketingCouponBO = MarketingCouponConvert.toBO(marketingCouponVO);
        return new ResultModel(marketingCouponHandler.update(marketingCouponBO));
	}


	/**
	 * 启用
	 */
	@RequestMapping("/enable")
	@ResponseBody
	public ResultModel enable(@RequestBody MarketingCouponVO marketingCouponVO){
		MarketingCouponBO marketingCouponBO = MarketingCouponConvert.toBO(marketingCouponVO);
		return new ResultModel(marketingCouponHandler.update(marketingCouponBO));
	}

	/**
	 * 禁用
	 */
	@RequestMapping("/disable")
	@ResponseBody
	public ResultModel disable(@RequestBody MarketingCouponVO marketingCouponVO){
		MarketingCouponBO marketingCouponBO = MarketingCouponConvert.toBO(marketingCouponVO);
		return new ResultModel(marketingCouponHandler.update(marketingCouponBO));
	}

}
